Ext.define('WT.controller.desktop.UserManagerController',{
	extend:'Ext.app.Controller',
	views:[
		'WT.view.desktop.usermanager.CreateUserView',
		'WT.view.desktop.usermanager.EditUserView'
	],
	init:function(){
		this.control({
			'button[id=user-manager-create-user]':{
				click:function(){
					Ext.create('WT.view.desktop.usermanager.CreateUserView');
				}
			},
			'button[id=update-manager-create-user]':{
				click:function(){
					Ext.create('WT.view.desktop.usermanager.EditUserView');
				}
			},
			//创建用户完成
			'button[id=create-user-finsh]':{
				click:function(){
				
				   var record = Ext.getCmp('createuser-role-grid').getSelectionModel().getSelection(); 
				   
				   var roleIds = "";
				  
				   if (record.length != 0)
				   {
					   for (var i = 0;i < record.length;i++)
					   {
						   roleIds += record[i].get("roleId");
						   if (i < record.length - 1)
						   {
							   roleIds = roleIds + ',';
						   }
					   }
				   }
				   
				 
				 var form = this.up('form').getForm(); 
				 
				 alert(form);
				 
				 form.submit({
					 url: 'test.jsp',
					 mthod:'post',
					 waitMsg: '表单正在提交......',
					 success: function(form, action) {
                          Ext.Msg.alert('Success', '保存成功!'); 
                          }, 
                          failure: function(form, action) { 
                        	  Ext.Msg.alert('Failed', '保存失败'); 
                          }
				 });
				  
				}
			}
		});
	}
});